<template>
  <div>
    <van-cell-group>
      <van-field
        v-model="registerParam.phoneNumber"
        required
        clearable
        type="tel"
        label="手机号"
        placeholder="请输入手机号"
      />

      <van-field
        v-model="registerParam.password"
        type="password"
        label="密码"
        placeholder="请输入密码"
        required
      />

      <van-field
        v-model="registerParam.msgCode"
        center
        clearable
        label="短信验证码"
        placeholder="请输入短信验证码"
      >
        <van-button slot="button" size="small" type="primary">发送验证码</van-button>
      </van-field>
    </van-cell-group>

    <van-row>
      <van-col span="24" style="text-align:center;padding: 20px;">
        <van-button round type="danger" size="large" @click="dubmitRegister">注册</van-button>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import { Field, Cell, CellGroup, Button, Row, Col, Toast, Divider } from "vant";
import { apiRegister } from "@/api/user";
export default {
  components: {
    [Field.name]: Field,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Button.name]: Button,
    [Row.name]: Row,
    [Col.name]: Col,
    [Toast.name]: Toast,
    [Divider.name]: Divider
  },
  data() {
    return {
      registerParam: {
        phoneNumber: "",
        password: "",
        msgCode: ""
      }
    };
  },
  methods: {
    dubmitRegister() {
      apiRegister(this.registerParam).then(res => {
        if (res.status === 0) {
          this.$router.push({
            name: "login"
          });
        } else {
          Toast(res.msg);
        }
      });
    }
  },
  created() {
    // this.orderSkus = this.$route.params.orderSkus;
    // console.log(this.orderSkus);
  }
};
</script>